<%--
  Created by IntelliJ IDEA.
  User: LENOVO
  Date: 2022/8/15
  Time: 13:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<head>
    <title>json测试</title>
</head>
<body>
    <script type="text/javascript">
        var user = {
            username:"zhangsan",
            password:"123"
        };

        /*对象转为json*/
        var userString = JSON.stringify(user);
        console.log(userString);//json格式的字符串
        /*json转为对象*/
        var user2 = JSON.parse(userString);
        console.log(user2.username,user2.password);//对象的属性值
    </script>
</body>
</html>
